home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Multimedia / Buzz 1.2 / BuzzME126.exe / gear / Effects / moveit.js < prev    next >
Encoding:
Text File  |  2001-08-26  |  3.7 KB  |  117 lines

  1. docTitle = "nothing yet"
  2. titleWidth = 0;
  3. titleHeight = 40;
  4. titleAlign = "topright";
  5.  
  6. //geniale Netscape vs. IE-Unterscheidung!
  7. var n = (document.layers)?1:0;
  8. var ie = (document.all)?1:0;
  9.  
  10. function startIt(docTitle2,titleWidth2) 
  11. {
  12.     docTitle=docTitle2;
  13.     titleWidth = titleWidth2; 
  14.     if (n || ie) 
  15.     {   
  16.         createLayer("watermark",null,0,0,titleWidth,titleHeight,"<font face='Verdana,Tahoma,sans-serif'><p align='right'><div align='right'><h1>"+docTitle+"</font></h1></div></p>",'#000000');
  17.         mark = new dynLayer("watermark");
  18.         setInterval("wtrmark()",130);
  19.     }
  20. }
  21.  
  22. function dynLayer(id,nestref) 
  23. {
  24.     if (n) {this.css = document.layers[id];}
  25.     else if (ie) {this.css = document.all[id].style;}
  26.     this.moveBy = dynLayerMoveBy;
  27.     this.moveTo = dynLayerMoveTo;
  28. }
  29.  
  30. function dynLayerMoveBy(x,y) 
  31. {
  32.     this.x += x;
  33.     this.css.left = this.x;
  34.     this.y += y;
  35.     this.css.top = this.y;
  36. }
  37.  
  38. function dynLayerMoveTo(x,y) 
  39. {
  40.     this.x = x;
  41.     this.css.left = this.x;
  42.     this.y = y;
  43.     this.css.top = this.y;
  44. }
  45. function wtrmark() 
  46. {
  47.     if (n) 
  48.     {
  49.         windowWidth = window.innerWidth-17;
  50.         windowHeight = window.innerHeight-17
  51.  
  52.         
  53.  
  54.         if (titleAlign == "topleft")    mark.moveTo(window.pageXOffset,window.pageYOffset)
  55.         if (titleAlign == "topright")   mark.moveTo(windowWidth-titleWidth+window.pageXOffset,window.pageYOffset);
  56.         if (titleAlign == "bottomleft") mark.moveTo(window.pageXOffset,windowHeight-titleHeight+window.pageYOffset)
  57.         if (titleAlign == "bottomright")mark.moveTo(windowWidth-titleWidth+window.pageXOffset,windowHeight-titleHeight+window.pageYOffset)
  58.     }
  59.     else 
  60.         if (ie) 
  61.         {
  62.             windowWidth = document.body.clientWidth
  63.             windowHeight = document.body.clientHeight
  64.             if (titleAlign == "topleft")    mark.moveTo(document.body.scrollLeft,document.body.scrollTop)
  65.             if (titleAlign == "topright")   mark.moveTo(windowWidth-titleWidth+document.body.scrollLeft,document.body.scrollTop)
  66.             if (titleAlign == "bottomleft") mark.moveTo(document.body.scrollLeft,windowHeight-titleHeight+document.body.scrollTop)
  67.             if (titleAlign == "bottomright")mark.moveTo(windowWidth-titleWidth+window.pageXOffset,windowHeight-titleHeight+document.body.scrollTop)
  68.         }
  69. }
  70.  
  71. function createLayer(id,nestref,left,top,width,height,content,bgColor,visibility,zIndex) 
  72. {
  73.     if (n) 
  74.     {
  75.         if (nestref) 
  76.             {var lyr = eval("document."+nestref+".document."+id+" = new Layer(width, document."+nestref+")")}
  77.             else 
  78.             {
  79.                 var lyr = document.layers[id] = new Layer(width);
  80.                 eval("document."+id+" = lyr");
  81.             }
  82.         lyr.name = id;
  83.         lyr.left = window.innerWidth - width;
  84.         lyr.top = top;
  85.         if (height!=null) lyr.clip.height = height;
  86.         if (bgColor!=null) lyr.bgColor = bgColor;
  87.         lyr.visibility = (visibility=='hidden')? 'hide' : 'show';
  88.         if (zIndex!=null) lyr.zIndex = zIndex;
  89.         if (content) 
  90.         {
  91.             lyr.document.open();
  92.             lyr.document.write(content);
  93.             lyr.document.close();
  94.         }
  95.     }
  96.     else if (ie) 
  97.         {
  98.             var str = '\n<DIV id='+id+' style="position:absolute; left:'+left+'; top:'+top+'; width:'+width;
  99.             if (height!=null) 
  100.             {
  101.                 str += '; height:'+height;
  102.                 str += '; clip:rect(0,'+width+','+height+',0)';
  103.             }
  104.             if (bgColor!=null) str += '; background-color:'+bgColor         
  105.             if (zIndex!=null) str += '; z-index:'+zIndex
  106.             if (visibility) str += '; visibility:'+visibility
  107.             str += ';">'+((content)?content:'')+'</DIV>'
  108.             if (nestref) 
  109.             {
  110.                 index = nestref.lastIndexOf(".")
  111.                 var nestlyr = (index != -1)? nestref.substr(index+1) : nestref
  112.                 document.all[nestlyr].insertAdjacentHTML("BeforeEnd",str);
  113.             }
  114.             else {document.body.insertAdjacentHTML("BeforeEnd",str)}
  115.            }
  116. }
  117.